<?php

use console\services\MigrateService;
use yii\db\Migration;

/**
 * Handles the creation of table `sys_city`.
 */
class m231229_144116_create_sys_city_table extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->createTable('sys_city', [
            'id' => $this->bigPrimaryKey(),
            'level' => $this->tinyInteger()->defaultValue(0)->notNull()->comment('省市级别'),
            'parent_id' => $this->bigInteger()->defaultValue(0)->notNull()->comment('上级ID'),
            'area_code' => $this->string(16)->defaultValue('')->notNull()->comment('区号'),
            'name' => $this->string(64)->defaultValue('')->notNull()->comment('名称'),
            'short_name' => $this->string(32)->defaultValue('')->notNull()->comment('简称'),
            'lng' => $this->string(32)->defaultValue('')->notNull()->comment('经度'),
            'lat' => $this->string(32)->defaultValue('')->notNull()->comment('纬度'),
            'status' => $this->string(1)->defaultValue('1')->notNull()->comment('是否展示'),
        ], MigrateService::createTableOptions('省市地区表'));
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('sys_city');
    }
}
